﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Objects;
using BAL;

public partial class Admin_UCControls_UCKhachHang_YeuCau : System.Web.UI.UserControl
{

    public DanhSachKhachHang ItemDanhSachKhachHang;
    public KhachHang itemKhachHang;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ItemDanhSachKhachHang = new DanhSachKhachHang();
            ItemDanhSachKhachHang = (DanhSachKhachHang)Session["ItemKhachHang"];

            if (ItemDanhSachKhachHang != null)
            {
                itemKhachHang = BALKhachHang.GetById(ItemDanhSachKhachHang.Id);

                GetThongtinKhachHang(itemKhachHang);

                DangKy ItemDangKy = new DangKy();
                ItemDangKy = BALDangKy.GetByIdKhachHang(ItemDanhSachKhachHang.Id);

                GetThongTinKhachHangTrenThe(ItemDangKy.IdKhachHangNhanThe);
            }       
        }
    }

    private void GetThongTinKhachHangTrenThe(int idKhachHang)
    {
        

        if (idKhachHang > 0)
        {

            KhachHangNhanThe ItemKhachHangNhanThe = new KhachHangNhanThe();
            ItemKhachHangNhanThe = BALKhachHangNhanThe.GetById(idKhachHang);
            lblHotenTrenThe.Text = ItemKhachHangNhanThe.Ten.ToString();
            lblNgaysinhTrenThe.Text = ItemKhachHangNhanThe.NgaySinh.ToShortDateString();
            if (ItemKhachHangNhanThe.GioiTinh.ToString() == "2")
            {
                lblGioiTinhTrenThe.Text = "Nữ";
            }
            else
            {
                lblGioiTinhTrenThe.Text = "Nam";
            }
            lblSoDienThoai.Text = ItemKhachHangNhanThe.DienThoaiNha.ToString();
            lblCMNDTrenThe.Text = ItemKhachHangNhanThe.CMND.ToString();
            lbldiaChiLLTrenThe.Text = ItemKhachHangNhanThe.DiaChiLienLac.ToString();
            lblDCTTrenThe.Text = ItemKhachHangNhanThe.DiaChiThuongTru.ToString();
            lblDTDDrenThe.Text = ItemKhachHangNhanThe.DienThoaiDiDong.ToString();
            lblEmailTrenThe.Text = ItemKhachHangNhanThe.Email.ToString();
        }
    }

    private void GetThongtinKhachHang(KhachHang khachHang)
    {
        lblHoTen.Text = khachHang.Ten.ToString();
        lblNgaySinh.Text = khachHang.NgaySinh.ToString("dd/MM/yyyy");
        lblSoDienThoai.Text = khachHang.DienThoaiNha.ToString();
        lblCMND.Text = khachHang.CMND.ToString();
        lblDiachi.Text = khachHang.DiaChiLienLac.ToString();
        lblDiaChiThuongTru.Text = khachHang.DiaChiThuongTru.ToString();
        lbldtdd.Text = khachHang.DienThoaiDiDong.ToString();
        lblEmail.Text = khachHang.Email.ToString();
        if (khachHang.GioiTinh.ToString() == "2")
        {
            lblGioitinh.Text = "Nữ";
        }
        else
        {
            lblGioitinh.Text = "Nam";
        }

    }
}
